﻿using System.Threading;

namespace sinetd.Protocols
{
    public class BaseProtocol : BaseManagerElement
    {
        #region cstor

        public BaseProtocol(string name) : base(name) { }

        public BaseProtocol(string name, string id) : base(name, id) { }

        #endregion

        #region Listen Thread

        protected bool TerminatePending = false;
        Thread listenThread;

        protected void StartThread(ThreadStart start)
        {
            TerminatePending = false;
            listenThread = new Thread(start);
            listenThread.Start();
        }

        protected void StopThread()
        {
            TerminatePending = true;
            if (listenThread != null) listenThread.Join(1000);
        }

        #endregion
    }
}
